package common.fengkai.filepost.utils;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
import common.fengkai.filepost.bean.excel.ExcelDemoBean;
import common.fengkai.filepost.dao.mysqldao.EmpUserMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;

/**
 * @author Fengkai
 * @creat 2022/9/14
 */
public class ExcelUtils {

    @Autowired
    private static EmpUserMapper empUserMapper;

    public static void  read(){
        String fileName = "";
        // 写法4
        fileName = "H:\\太平印章项目\\签约产品导入模板.xlsx";
        File file = new File("H:\\太平印章项目\\签约产品导入模板.xlsx");
        // 一个文件一个reader
        try (ExcelReader excelReader = EasyExcel.read(file, ExcelDemoBean.class, new DemoDataListener(empUserMapper)).build()){
            // 构建一个sheet 这里可以指定名字或者no
            ReadSheet readSheet = EasyExcel.readSheet(0).build();
            // 读取一个sheet
            excelReader.read(readSheet);
        }
    }


       public static void main(String[] args){
           ExcelUtils.read();
          }
}


